# -*- coding: utf-8 -*-
# @Time    : 2021/5/7 17:49
# @Author  : mokez
# @Email   : mokez@qq.com
# @File    : 面向对象作业.py
# @Software: PyCharm

# atm
# class Atm():
#     # 金额
#     def __init__(self, atm_money):
#         self.atm_money = atm_money
#
#     # 存钱
#     def atm_save(self, money):
#         self.atm_money += money
#         print(f"给atm存了{money},atm中还有{self.atm_money}")
#
#     # 取钱
#     def atm_draw(self, money):
#         self.atm_money -= money
#         print(f"您从atm中取了{money},atm中还有{self.atm_money}")
#
#
#
# class User():
#     def __init__(self, username, password, user_money):
#         self.user_money = user_money
#         self.username = username
#         self.password = password
#
#     def user_save(self, money, atm):
#         self.user_money += money
#         atm.atm_money += money
#         print(f"您存了{money},您有{self.user_money},atm中还有{atm.atm_money}")
#
#     def user_draw(self, money, atm):
#         if atm.atm_money >= money and self.user_money >= money:
#             atm.atm_money -= money
#             self.user_money -= money
#             print(f"您取了{money},您还有{self.user_money},atm中还有{atm.atm_money}")
#         else:
#             print("atm余额不足或您的余额不足")
#
# username = input("请输入您的用户名:")
# password = input("请输入您的密码:")
# user = User(username, password, 50000)
# atm = Atm(10000)
# while 1:
#     print("请问您需要进行什么操作？")
#     print("1.账户取钱")
#     print("2.账户存钱")
#     print("3.账户查询")
#     print("4.ATM取钱")
#     print("5.ATM存钱")
#     print("6.ATM查询")
#     an = input("输入编号(按q退出):")
#
#     if an == "1":
#         money = int(input("请问需要取多少钱:"))
#         user.user_draw(money, atm)
#     elif an == "2":
#         money = int(input("请问需要存多少钱:"))
#         user.user_save(money, atm)
#     elif an == "3":
#         print(f"您的余额为{user.user_money}")
#         input("按任意键返回菜单")
#     elif an == "4":
#         money = int(input("请问ATM需要取多少钱:"))
#         atm.atm_draw(money)
#     elif an == "5":
#         money = int(input("请问ATM需要存多少钱:"))
#         atm.atm_save(money)
#     elif an == "6":
#         print(f"ATM的余额为{user.user_money}")
#         input("按任意键返回菜单")
#     elif an == "q":
#         print("谢谢光临！")
#         break
#     else:
#         print("请重新输入！")

# 斐波那契
# class Fibonacci(object):
#     """斐波那契数列迭代器"""
#
#     def __init__(self, n):
#         """
#         :param n:int 指 生成数列的个数
#         """
#         self.n = n
#         # 保存当前生成到的数据列的第几个数据，生成器中性质，记录位置，下一个位置的数据
#         self.current = 0
#         # 两个初始值
#         self.a = 0
#         self.b = 1
#
#     def __next__(self):
#         """当使用next()函数调用时，就会获取下一个数"""
#         if self.current < self.n:
#             self.a, self.b = self.b, self.a + self.b
#             self.current += 1
#             return self.a
#         else:
#             raise StopIteration
#
#     def __iter__(self):
#         """迭代器的__iter__ 返回自身即可"""
#         return self
#
#
# if __name__ == '__main__':
#     fib = Fibonacci(5)
#     for num in fib:
#         print(num)
